/**
* @file test_cyril.h
*
*/

#ifndef  __TEST_CYRIL_H__
#define __TEST_CYRIL_H__

#ifdef __cplusplus
extern "C" {
#endif
/*********************
*      INCLUDES
*********************/
#if 0
#include <Windows.h>
#include "../lvgl/lvgl.h"
#include "../lvgl/examples/lv_examples.h"
#include "../lv_demos/lv_demo.h"
#include "../lv_drivers/win32drv/win32drv.h"
#include "../lv_lib_freetype/lv_freetype.h"
#endif
	
#include "../gui/gui.h"
#include "main.h"
#include "locate.h"
#include "cmsis_os.h"
#include <stdio.h>


/*********************
*      DEFINES
*********************/

    //原始分辨率
#define LCD_RAW_HOR_RES 128
#define LCD_RAW_VER_RES 160

//分辨率放大系数
#define LCD_RES_SCALER 1

//真实分辨率
#define LCD_HOR_RES  LCD_RAW_HOR_RES*LCD_RES_SCALER
#define LCD_VER_RES  LCD_RAW_VER_RES*LCD_RES_SCALER

//按键事件
#define FB_DATA_PRESS 1
#define FB_MAP_PRESS  2
#define MAP_RETURN_PRESS 3

//地图界面地图大小
#define MP_CHART_WIDTH 128
#define MP_CHART_HEIGHT 130

//UWB配置项
#define UWB_ANCHOR_NUM 4
#define ANCHOR_1 0
#define ANCHOR_2 1
#define ANCHOR_3 2
#define ANCHOR_4 3

//坐标未设置
#define POS_NO_SET 0xFF

//图表坐标偏移
#define POINT_BIAS 10

//RSSI信号值的最大值
#define RSSI_MAX 65535

//标签设备ID
#define TAG_ID 402

 //默认选项宏
#define DEFAULT -1

//基站LED 状态
#define ON 1
#define OFF 0
/**********************
*      TYPEDEFS
**********************/
//页面ID
typedef enum {
		PAGE_DATA = 1,
		PAGE_MAP = 2,
		NO_PAGE = 10,
}page_id_t;

//GUI UWB相关数据
//可直接修改：anchor_addr  anchor_rssi  tag_dist  tag_x  tag_y
typedef struct {
		/* UWB相关数据 */
		//基站地址
		uint32_t anchor_addr[UWB_ANCHOR_NUM];
		//基站状态    在线：1  离线：0
		uint8_t anchor_sta[UWB_ANCHOR_NUM];
		//基站位置
		float anchor_base_x[UWB_ANCHOR_NUM];
		float anchor_base_y[UWB_ANCHOR_NUM];
		//基站RSSI信号值
		uint16_t anchor_rssi[UWB_ANCHOR_NUM];
		//当前可用基站数
		uint8_t anchor_count;
		//标签位置
		uint8_t tag_x;
		uint8_t tag_y;
		//标签距离基站的距离
		float tag_dist[UWB_ANCHOR_NUM];

		/* LVGL相关 */
		//LVGL基站LED
		lv_obj_t* anchor_led[UWB_ANCHOR_NUM];
		//标签图标
		lv_obj_t* tag_icon;
		//标签图标风格
		lv_style_t tag_icon_style;
		//标签距离label
		lv_obj_t* tag_dist_label[UWB_ANCHOR_NUM];
		//标签距离label风格
		lv_style_t tag_dist_label_style;
		//基站RSSI信号条
		lv_obj_t* anchor_rssi_bar[UWB_ANCHOR_NUM];
		//基站RSSI信号条风格
		lv_style_t anchor_rssi_bar_style;
		//标签坐标label
		lv_obj_t* tag_pos_label;
		//标签坐标label风格
		lv_style_t tag_pos_label_style;
}gui_uwb_data_t;

//GUI全局数据
//可直接修改：bat_val angle_val tag_id
typedef struct {
		//电池电量，百分比
		uint8_t bat_val;
		//标签ID
		uint16_t tag_id;
		//当前页面ID
		page_id_t cur_page;
		//当前磁力计角度
		float angle_val;
}gui_global_data_t;

/**********************
*  GLOBAL PROTOTYPES
**********************/

extern gui_uwb_data_t gui_ud;
extern gui_global_data_t gui_gd;
extern float axis_fa_x;
extern float axis_fb_x;
extern float axis_fa_y;
extern float axis_fb_y;

void Test_Cyril_Init(void);
void Test_Cyril_Loop(void);

void Gui_UwbDataInit(void);
void Gui_UwbSetAnchorPos(float* input_x, float* input_y);
void Gui_UwbSetAnchorRssi(uint16_t* input_rssi);
void Gui_UwbSetTagPos(int16_t x, int16_t y, float angle);
void Gui_UwbSetTagDist(float* tag_dist_val);
void Gui_UwbSetStaLabel(void);
void Gui_Update(void);

void Gui_SetBatVal(uint8_t bat_val);
void Gui_SetTagID(int16_t tag_id);
void Gui_SetAddr(uint32_t anchor1_addr, uint32_t anchor2_addr, uint32_t anchor3_addr);
void Gui_SetAnchorSta(uint8_t id, uint8_t on_off);

/**********************
*      MACROS
**********************/

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif




